package com.epalmpay.controller.manage.message;

import com.epalmpay.commom.BaseController;
import com.epalmpay.dto.messsage.AppNoticeInDTO;
import com.epalmpay.dto.messsage.AppNoticeListOutDTO;
import com.epalmpay.dto.system.PageDTO;
import com.epalmpay.entity.Page;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.service.app.IAppNoticeService;
import com.epalmpay.status.Rescode;
import com.epalmpay.util.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2018/3/16.
 */
@Controller
@RequestMapping(value="channel/appnotice")
public class AppNoticeController extends BaseController{

    @Resource
    private IAppNoticeService appNoticeService;

    @ResponseBody
    @RequestMapping(value = "/list")
    public AppNoticeListOutDTO list(AppNoticeInDTO appNoticeInDTO, PageDTO pageDTO)throws Exception{
        AppNoticeListOutDTO appNoticeListOutDTO = new AppNoticeListOutDTO();
        try {
            Page page= Tools.pageEmtity(pageDTO);
            appNoticeListOutDTO= appNoticeService.queryAppNoticeList(appNoticeInDTO,page);

            appNoticeListOutDTO.setErrorCode(Rescode.SUCCESS, "处理成功");

            appNoticeListOutDTO.setPage(page);
            return appNoticeListOutDTO;
        } catch (ApplicationException ae) {
            appNoticeListOutDTO.setErrorCode(ae.errCode, ae.errMsg);
            ae.printStackTrace();
        }
        catch (Exception e) {
            appNoticeListOutDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
            e.printStackTrace();
        }
        return appNoticeListOutDTO;

    }



}
